<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>PHP 7.0.x 弃用的功能</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="migration70.new-features.html">« 新特性</a></li>
      <li style="float: right;"><a href="migration70.changed-functions.html">变更的函数 »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="migration70.html">从 PHP 5.6.x 移植到 PHP 7.0.x</a></li>
    <li>PHP 7.0.x 弃用的功能</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="migration70.deprecated" class="sect1">
 <h2 class="title">PHP 7.0.x 弃用的功能</h2>


 

 <div class="sect2" id="migration70.deprecated.php4-constructors">
  <h3 class="title">PHP4 风格的构造函数</h3>

  <p class="para">
   PHP4 风格的构造函数（方法名和类名一样）将被弃用，并在将来移除。
   如果在类中仅使用了 PHP4 风格的构造函数，PHP7 会产生 <strong><code>E_DEPRECATED</code></strong> 警告。
   如果还定义了 <span class="function"><strong>__construct()</strong></span> 方法则不受影响。
  </p>

  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">foo</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'I&nbsp;am&nbsp;the&nbsp;constructor'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <p class="para">以上例程会输出：</p>
   <div class="example-contents screen">
<div class="cdata"><pre>
Deprecated: Methods with the same name as their class will not be constructors in a future version of PHP; foo has a deprecated constructor in example.php on line 3
</pre></div>
   </div>
  </div>
 </div>


 <div class="sect2" id="migration70.deprecated.static-calls">
  <h3 class="title">静态调用非静态的方法</h3>

  <p class="para">
   废弃了 <a href="language.oop5.static.html" class="link">静态（Static）</a> 调用未声明成 <strong class="command">static</strong> 的方法，未来可能会彻底移除该功能。
  </p>

  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">foo&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;function&nbsp;</span><span style="color: #0000BB">bar</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">'I&nbsp;am&nbsp;not&nbsp;static!'</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /><br /></span><span style="color: #0000BB">foo</span><span style="color: #007700">::</span><span style="color: #0000BB">bar</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <p class="para">以上例程会输出：</p>
   <div class="example-contents screen">
<div class="cdata"><pre>
Deprecated: Non-static method foo::bar() should not be called statically in - on line 8
I am not static!
</pre></div>
   </div>
  </div>
 </div>
 
 <div class="sect2" id="migration70.deprecated.pwshash-salt-option">
  <h3 class="title"><span class="function"><a href="function.password-hash.html" class="function">password_hash()</a></span> 盐值选项</h3>

  <p class="para">
   废弃了 <span class="function"><a href="function.password-hash.html" class="function">password_hash()</a></span> 函数中的盐值选项，阻止开发者生成自己的盐值（通常更不安全）。
   开发者不传该值时，该函数自己会生成密码学安全的盐值。因此再无必要传入自己自定义的盐值。
  </p>
 </div>
 
 <div class="sect2" id="migration70.deprecated.capture-session-meta">
  <h3 class="title"><code class="literal">capture_session_meta</code> SSL 上下文选项</h3>

  <p class="para">
   废弃了 <code class="literal">capture_session_meta</code> 内的 SSL 上下文选项。
   现在可以通过 <span class="function"><a href="function.stream-get-meta-data.html" class="function">stream_get_meta_data()</a></span> 获取 SSL 元数据（metadata）。
  </p>
 </div>
 
 <div class="sect2" id="migration70.deprecated.ldap">
  <h3 class="title"><a href="book.ldap.html" class="link">LDAP</a> 中的废弃</h3>
   <p class="simpara">
    以下函数已被废弃：
   </p>

   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      <span class="function"><a href="function.ldap-sort.html" class="function">ldap_sort()</a></span>
     </span>
    </li>
   </ul>
 </div>

</div></div></div></body></html>